import {securityCheck} from "@/api/api";
// import axios from 'axios'
import $ from "jquery" 
export function getToken(){
    var token = sessionStorage.token
    if (token == undefined) {
        sessionStorage.clear()
        return false
    } 
    else {
        if (Check(token)){
            return true
        }
        sessionStorage.clear()
        return  false
    }

    return true
    
}


function Check(token) {
    let par = {"token":token.replace(`"`,"").replace(`"`,"")}
        var DataJson = JSON.stringify(par);
        var res = false;
        $.ajax({
            url: "/v1/security/check",
            type: 'post',
            contentType: 'application/json',
            data:DataJson,
            async: false, // 同步
            success: function (result) {
                let {code,data,msg} = result;
                if (code == 200) {
                    res = true;
                    return true
                }
            }
        });
        return res
}


